package sengine;

import game.Equipment;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.lwjgl.input.Keyboard;

/**
 *
 * @author rmatti0050
 */
public class PartyCharacter extends Character {

    private String current="luigi.png";
    
    private boolean spaceDown = false;
    private int lastXKey = 0;
    private PlayerCharacter player;
    private ArrayList<Equipment> weapons=new ArrayList<>();

    public PartyCharacter(PlayerCharacter player) {
        super((int) player.getX() - 40, (int) player.getY(), 25, 25);
        setPhysType(Object2D.PhysicsType.FLOATING);
        this.player = player;
    }
    public void setCurrent(String current) {
        this.current = current;
    }

    @Override
    public void update(long millis) {
        if (Keyboard.isKeyDown(Keyboard.KEY_A) && Keyboard.isKeyDown(Keyboard.KEY_D)) {
            stopMove();
            stationarySprite();
        } else if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
//            moveLeft();
            leftSprite();
            lastXKey = Keyboard.KEY_A;
        } else if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
//            moveRight();
            rightSprite();
            lastXKey = Keyboard.KEY_D;
        } else {
            stopMove();
            stationarySprite();
        }

        if (Keyboard.isKeyDown(Keyboard.KEY_SPACE) && !spaceDown) {
            jump();
            inAir();
            spaceDown = true;
        } else if (!Keyboard.isKeyDown(Keyboard.KEY_SPACE) && spaceDown) {
            spaceDown = false;
        }
        super.update(millis);
    }

    public void stationarySprite() {
        setY((int) player.getY());
        setVy(0);
        if (lastXKey == Keyboard.KEY_A) {
            leftSprite();
        } else if (lastXKey == Keyboard.KEY_D) {
            rightSprite();
        }
    }

    public void leftSprite() {
        setTexture(Texture.loadTexture("left"+current));
        setX((int) player.getX() + 65);
        setY((int) player.getY());
        setVy(0);
    }

    public void rightSprite() {
        setTexture(Texture.loadTexture("right"+current));
        setX((int) player.getX() - 40);
        setY((int) player.getY());
        setVy(0);
    }

    @Override
    //Override to do nothing
    public void inAir() {
    }

    @Override
    //Override to do nothing
    public void onGround() {
    }
}
